import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  list = '/shortlink-service/linkAccessLog/pageAccessLog',
  deleteBatch = '/shortlink-service/linkAccessLog/batchDeleteAccessLog',
}

/**
 * 查询列表
 * @param params
 */
export const listAccessLog = (params) => {
  return defHttp.get({ url: Api.list, params });
};

/**
 * 删除
 * @param params
 */
export const batchAccessLog = (params, handleSuccess) => {
  return defHttp.delete({
    url: Api.deleteBatch, data: {
      ids: [
        params.id
      ]
    }
  }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};

/**
 * 批量删除
 * @param params
 */
export const batchDeleteAccessLog = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};
